package com.cskaoyan._08game._04invokeflow;

/**
 * @description:
 * @author: 景天
 * @date: 2023/2/6 10:50
 **/
/*
类加载:
1.执行main之前要进行类加载
2.首次创建某个类对象之前,触发类加载

赋值顺序:
1.默认初始化(第一步)
2.显示赋值
3.构造方法赋值(最后一步)

 */
public class Demo {
    public static void main(String[] args) {
        Student s = new Student(18, "长风");
        System.out.println(s.age);
        System.out.println(s.name);
        System.out.println(s.var);
        System.out.println(s.cat.price);
    }
}
class Student {
    int age = 10;
    String name = "张三";
    double var = 20;

    public Student(int age) {
        System.out.println("Student age");
        this.age = age;
    }

    public Student() {
    }

    public Student(int age, String name) {
        this(age);
        System.out.println("Student age,name");
        this.name = name;
    }

    Cat cat = new Cat(1000);
    Cat c2;
}

class Cat {
    double price;

    public Cat() {
    }

    public Cat(double price) {
        System.out.println("Cat price");
        this.price = price;
    }
}
